package swu.cx.progressbar
import android.animation.ValueAnimator
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main.view.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        //2.设置回调函数的具体实现
        mProgress.callBack = {
            //做下载任务
            downloadData()
        }


    }

    private fun downloadData(){
        ValueAnimator.ofFloat(0f,1.0f).apply {
            duration = 2000
            addUpdateListener {
                (it.animatedValue as Float).also { value ->
                    mProgress.progress = value
                }

            }
            start()
        }
    }
}
